﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "FTPManager.h"
#include "FileFunction.h"
#include "FileEncodeManager.h"
#include <QMainWindow>
#include <QFileInfo>
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QTextEdit>

enum TRANSFER_STATUS
{
    NULL_FILELIST = -1,
    SUCCESS_TRANSMISSION,
    ERROR_ON_TRANSMISSION,
};

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QMainWindow *parent = nullptr);
    ~MainWindow();
    void showFTPStatus(int ret);
private:
    Ui::MainWindow *ui;

    QLabel *m_ipLabel;
    QLineEdit *m_ipLineEdit;

    QLabel *m_portLabel;
    QLineEdit *m_portLineEdit;

    QLabel *m_userLabel;
    QLineEdit *m_userLineEdit;

    QLabel *m_passwordLabel;
    QLineEdit *m_passwordLineEdit;

    QPushButton *m_openDirBtn;

    QLineEdit *m_localUploadFilePathLineEdit;

    QLineEdit *m_localPathLineEdit;
    QLineEdit *m_remoteFtpPathLineEdit;

    QPushButton *m_uploadBtn;

    QPushButton *m_downloadBtn;

    FTPManager *m_updownloadFileWork;

    FileEncodeManager *m_fileEncodeManger;
    QPushButton *m_setmd5fileRootBtn;
    QLineEdit *m_md5fileRootEdit;
    QPushButton *m_createMd5fileRootBtn;

    QString ip;
    QString port;
    QString userName;
    QString userPassword;
    QString localRootPath;//本地文件目录
    QString remoteFtpRootPath;//FTP服务器目录
    QString md5EncodeFileRoot;//需要md5编码的文件路径

    FileInfoList st_fileInforList;

    unsigned int successfulFileNum;
    int ret;//返回的状态量

signals:
    int evt_beginFTPUpLoad();
    int evt_beginFTPDownLoad();
    int evt_fileEncode();
public slots:
    void on_openFile();
    void on_upLoad();
    void on_downLoad();
    void on_finishOneFileTransfer();
    void on_setEncodeFileRoot();
    void on_beginFileEncode();
};
#endif // MAINWINDOW_H
